Ext.define('CDR.view.TariffCallLogAMQ', {
	extend: 'CDR.view.TariffAMQ',
	alias: 'widget.tariff-amq-call-log',
	myId: "CALL.LOG",
	layout: 'fit',
	store: null,
	initComponent: function(){
		var me = this;
		me.callParent(arguments);
		//adding view
		me.view = Ext.createWidget('gridpanel', {
			id: 'cdr-tariff-amq-call-log-view',
			autoScroll: true,
			viewConfig: { 
		        stripeRows: false, 
		        getRowClass: function(record) { 
		            return (record.get('discount') == 'Holiday' || record.get('discount') == 'Offpeak') ? 'discount-row' : ''; 
		        } 
		    }, 
			store: me.store,
			columns: [{
				header: 'Trunk Id',  
				dataIndex:'trunkId', 
				menuDisabled: true,
				flex: 1
			},{
				header: 'Employee Id',  
				dataIndex:'employeeId', 
				menuDisabled: true,
				flex: 1
			},{
				header: 'Employee Name',  
				dataIndex:'employeeName', 
				menuDisabled: true,
				flex: 1
			},{
				header: 'Calling Num',  
				dataIndex:'callingNum', 
				menuDisabled: true,
				flex: 1
			},{
				header: 'Dialed Num',  
				dataIndex:'dialedNum', 
				menuDisabled: true,
				flex: 1
			},{
				header: 'Destination',  
				dataIndex:'destination', 
				menuDisabled: true,
				flex: 1
			},{
				header: 'StartDate',  
				dataIndex:'startDate', 
				menuDisabled: true,
				flex: 1
			},{
				header: 'Duration',  
				dataIndex:'duration', 
				menuDisabled: true,
				flex: 1
			},{
				header: 'EndDate',  
				dataIndex:'endDate', 
				menuDisabled: true,
				flex: 1
			},{
				header: 'Price',  
				dataIndex:'price', 
				menuDisabled: true,
				flex: 1
			},{
				header: 'Discount',  
				dataIndex:'discount', 
				menuDisabled: true,
				flex: 1
			}]
		});
		me.add(me.view);
		
	},
	getAMQSelector: function(){
		if(CDR.Constant.User.id){
			return {selector: "type='call' AND  employee='"+ CDR.Constant.User.id +"'"};
		}
		return {selector: "type='call'"};
	},
	handleMessage: function(message){
		//console.log("call data receive>>: ", message.nodeValue);
		var view = Ext.getCmp('cdr-tariff-amq-call-log-view');
		var data = Ext.decode(message.nodeValue);
		view.store.insert(0, [data]);
		if(view.store.count() > 100){
			view.store.removeAt(view.store.count()-1);			
		}
	}
	
});